package com.leyou.item;

import com.leyou.common.vo.PageResult;

import com.leyou.item.pojo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 黑马程序员
 */
@FeignClient("item-service")
public interface ItemClient {

    //查询所有Spu  分页查询
    @GetMapping("/spu/page")
    public PageResult<SpuDTO> goodsPageQuery(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                             @RequestParam(value = "rows", defaultValue = "5") Integer rows,
                                             @RequestParam(value = "key", required = false) String key,
                                             @RequestParam(value = "saleable", required = false) Boolean saleable);

    //根据spuId查询skus   有了
    @GetMapping("/sku/of/spu")
    public List<SkuDTO> findSkusBySpuId(@RequestParam("id") Long id);

    @GetMapping("/spec/params")
    public List<SpecParamDTO> findSpecParamsByGid(@RequestParam(value = "gid", required = false) Long gid,
                                                  @RequestParam(value = "cid", required = false) Long cid,
                                                  @RequestParam(value = "searching", required = false) Boolean searching);

    @GetMapping("/spu/detail")
    public SpuDetailDTO findSpuDetailBySpuId(@RequestParam("id") Long id);

    @GetMapping("/category/list")
    public List<CategoryDTO> queryCategoryByIds(@RequestParam("ids") List<Long> idList);

    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandByIds(@RequestParam("ids") List<Long> idList);

    @GetMapping("spu/{id}")
    SpuDTO querySpuById(@PathVariable("id") Long id);

    /**
     * 查询规格参数组，及组内参数
     * @param id 商品分类id
     * @return 规格组及组内参数
     */
    @GetMapping("/spec/of/category")
    List<SpecGroupDTO> querySpecsByCid(@RequestParam("id") Long id);

    @GetMapping("/brand/of/spu")
    public BrandDTO queryBrandByid(@RequestParam("id") Long id);
}